package main

import "fmt"

func max(num1, num2 int) int{
   var result int
   if(num1 > num2){
   	result = num1
   }else{
   	result = num2
   }
   return result
}

func main() {
   //func
   
   var fa int = 100
   var fb int = 200
   var ret int
   
   ret = max(fa, fb)
   fmt.Printf("max value:  %d \n", ret)
   
   a, b := swap("Mesh", "Mdl")
   fmt.Println(a, b)
   
   testArray()
   
   testPtr()
}

func swap(str1, str2 string)(string, string){
    return str2, str1
}

func testArray(){
    var nArr [10] int
    var i, j int
    
    for i = 0;i<10;i++{
        nArr[i] = i + 100
    }
    
    for j = 0; j<10; j++{
    	fmt.Println(nArr[j])
    }
}

func testPtr(){
    var a int= 20;
    var ip *int
    
    fmt.Println(ip)
    
    if(ip == nil){
    	ip = &a
    }
    
    fmt.Println(*ip)
    
    var pptr **int
    pptr = &ip
    fmt.Println(**pptr)
    
    var b int = 30
    swapPtr(&a, &b)
    fmt.Println(a, b)
}

func swapPtr(x *int, y *int){
    *x, *y = *y, *x
}



